Feature/refactor mui table#264
Conversation
📝 WalkthroughWalkthroughThis PR refactors MUI table styling to centralize cell layout composition and introduces conditional disabling of action buttons via an ChangesConditional Action Button Disabling in MUI Table
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/mui/table/mui-table.js (1)
108-109: ⚡ Quick winCentralize and boolean-normalize row disabled evaluation.
options.disableProp && row[options.disableProp]is duplicated and returns non-boolean values. Extracting a single helper withBoolean(...)avoids divergence and prevents accidental disabling from truthy non-boolean payloads.Suggested refactor
+ const isRowDisabled = (row) => + Boolean(options.disableProp && row?.[options.disableProp]); + + const isArchiveDisabled = (row) => + Boolean(options.disableProp && options.disableProp !== "is_archived" && row?.[options.disableProp]); + const getDisabledSx = (row) => - options.disableProp && row[options.disableProp] ? ARCHIVED_CELL_SX : {}; + isRowDisabled(row) ? ARCHIVED_CELL_SX : {}; ... - disabled={options.disableProp && row[options.disableProp]} + disabled={isRowDisabled(row)} ... - disabled={options.disableProp && options.disableProp !== "is_archived" && row[options.disableProp]} + disabled={isArchiveDisabled(row)} ... - disabled={options.disableProp && row[options.disableProp]} + disabled={isRowDisabled(row)} ... - disabled={options.disableProp && row[options.disableProp]} + disabled={isRowDisabled(row)}Also applies to: 247-248, 274-275, 295-296, 313-314
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/mui/table/mui-table.js` around lines 108 - 109, Extract a single helper (e.g., isRowDisabled) that returns a boolean using Boolean(options.disableProp && row[options.disableProp]) and replace the duplicated checks (currently used in getDisabledSx and the other occurrences around the file) with calls to that helper; ensure getDisabledSx(row) uses isRowDisabled(row) to return ARCHIVED_CELL_SX or {} and update the other spots (the duplicated expressions at the listed locations) to use the same helper so the disabled evaluation is centralized and always yields a true boolean.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/components/mui/table/mui-table.js`:
- Around line 108-109: Extract a single helper (e.g., isRowDisabled) that
returns a boolean using Boolean(options.disableProp && row[options.disableProp])
and replace the duplicated checks (currently used in getDisabledSx and the other
occurrences around the file) with calls to that helper; ensure
getDisabledSx(row) uses isRowDisabled(row) to return ARCHIVED_CELL_SX or {} and
update the other spots (the duplicated expressions at the listed locations) to
use the same helper so the disabled evaluation is centralized and always yields
a true boolean.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 570c4107-c5eb-4379-8640-18cd68610db6
📒 Files selected for processing (3)
package.jsonsrc/components/mui/__tests__/mui-table.test.jssrc/components/mui/table/mui-table.js
https://app.clickup.com/t/86baay28c
Adding cellSx and headSx to columnOptions to allow style definition by column
Fix Action Cells not being affected by disableProp
Summary by CodeRabbit
New Features
Tests
Chores